﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TracNghiemV1.Database;
using TracNghiemV1.DAO;


namespace TracNghiemV1.BUS
{
    class QuestionItemBus
    {
        public static void AddQuestionItem(string itemDescription, bool isSolution, int questionId)
        {
            QUESTION_ITEM newQI = new QUESTION_ITEM();
            newQI.QUESTION_ID = questionId;
            newQI.ITEM_FACE = "NO";
            newQI.ITEM_VALUE = "NO";
            QuestionItemDao.AddQuestionItem(newQI);

            QUESTION_ITEM_INFO newQII = new QUESTION_ITEM_INFO();
            newQII.ITEM_INFO_PROP = "NO";
            newQII.ITEM_INFO_VALUE = itemDescription;
            newQII.ITEM_ID = newQI.ITEM_ID;
            QuestionItemInfoDao.AddQuestionItemInfo(newQII);

            if (isSolution)
            {
                QUESTION_SOLUTION newQS = new QUESTION_SOLUTION();
                newQS.QUESTION_ID = questionId;
                newQS.ITEM_ID = newQI.ITEM_ID;
                QuestionSolutionDao.AddQuestionSlolution(newQS);
            }
        }

        public static void ModifieddQuestionItemInfo(QUESTION_ITEM_INFO qit)
        {
            QuestionItemInfoDao.ModifyQuestionItemInfo(qit);
        }
    }
}
